<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>AdminLTE 2 | Log in</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<link href="${rc.contextPath}/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="${rc.contextPath}/AdminLTE/dist/css/AdminLTE.min.css">
<!-- iCheck -->
<link rel="stylesheet" href="${rc.contextPath}/AdminLTE/plugins/iCheck/square/blue.css">
<link href="${rc.contextPath}/AdminLTE/bootstrap/css/bootstrapValidator.min.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->
</head>
<body class="hold-transition login-page">
	<!-- 项目路径 -->
	<input type="hidden" id="namespaceUrl" value="${rc.contextPath}/">
	<div class="login-box">
		<div class="login-logo">
<!-- 			<a href="../../index2.html"><b>简易的</b>管理后台</a> -->
		</div>
		<!-- /.login-logo -->
		<div class="login-box-body">
			<p class="login-box-msg">后台管理平台</p>

			<form>
				<div class="form-group has-feedback">
					<input id="email" name="email" type="text" class="form-control" placeholder="邮箱/用户名"> <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
				</div>
				<div class="form-group has-feedback">
					<input id="password" name="password" type="password" class="form-control" placeholder="密码"> <span class="glyphicon glyphicon-lock form-control-feedback"></span>
				</div>
				<div class="row">
					<div class="col-xs-8">
						<div class="checkbox icheck">
							<label> <input type="checkbox"> 记住我
							</label>
						</div>
					</div>
					<!-- /.col -->
					<div class="col-xs-4">
						<button type="submit" class="btn btn-primary btn-block btn-flat">登 录</button>
					</div>
					<!-- /.col -->
				</div>
			</form>

			<div class="social-auth-links text-center">
				
				<p>- 其他登录方式 -</p><!-- 
				<a href="#" class="btn btn-block btn-social btn-twitter btn-flat">
					<i class="fa fa-qq"></i>用QQ账号登录
				</a> 
				<a href="#" class="btn btn-block btn-social btn-google btn-flat">
					<i class="fa fa-weibo"></i>用微博账号登录
				</a>
					 -->
				<a href="#" title="微信登录"><i class="fa fa-wechat fa-lg"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;
				<a href="#" title="QQ登录"><i class="fa fa-qq fa-lg"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;
			</div>
			<!-- /.social-auth-links -->

			<a href="#">忘记密码?</a><br> <a href="register.html" class="text-center">立即注册</a>

		</div>
		<!-- /.login-box-body -->
	</div>
	<!-- /.login-box -->

	<!-- jQuery 2.2.3 -->
	<script src="${rc.contextPath}/AdminLTE/plugins/jQuery/jquery-2.2.3.min.js"></script>
	<script src="${rc.contextPath}/AdminLTE/bootstrap/js/bootstrap.min.js"></script>
	<!-- iCheck -->
	<script src="${rc.contextPath}/AdminLTE/plugins/iCheck/icheck.min.js"></script>
	<!-- bootstrapValidator -->
	<script src='${rc.contextPath}/AdminLTE/bootstrap/js/bootstrapValidator.min.js'></script>
	<script>
		$(function() {
			$('input').iCheck({
				checkboxClass : 'icheckbox_square-blue',
				radioClass : 'iradio_square-blue',
				increaseArea : '20%' // optional
			});
			
			formValidator();
		});
		
		//form验证规则
		function formValidator() {
			// 表单验证
			$("form").bootstrapValidator({
				message : 'This value is not valid',
				feedbackIcons : {
					valid : 'glyphicon glyphicon-ok',
					invalid : 'glyphicon glyphicon-remove',
					validating : 'glyphicon glyphicon-refresh'
				},
				fields : {
					email : {
						message : '邮箱或密码验证失败',
						validators : {
							notEmpty : {
								message : '邮箱或用户名不能为空'
							}
						}
					},
					password : {
						message : '密码验证失败',
						validators : {
							notEmpty : {
								message : '密码不能为空'
							}
						}
					}
				}
			}).on('success.form.bv', function(e) {
				// 阻止默认form事件提交
				e.preventDefault();

				/** ajax提交表单* */
				//参数对象
				var param = new Object();
				param.email = $("#email").val();
				param.password = $("#password").val();
				$.ajax({
					url : "loginVerification",
					dataType : "JSON",
					data : param,
					success : function(data) {
						if (data.code == 0 && data.certification) {
							location.href = $("#namespaceUrl").val() + "/admin/";
						} else {
							// 调用失败提示
							alert("error");
						}
					},
					error : function(XMLHttpRequest, textStatus, errorThrown) {
						// 调用失败提示
						alertDivFadeSet(2, 1000, function() {
							console.log(XMLHttpRequest.status);
							console.log(XMLHttpRequest.readyState);
							console.log(textStatus);
						});
					}
				})
			});
		}
	</script>
</body>
</html>
